﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Test
{
    public partial class Form2 : Form
    {

        private readonly string REPORTS_FILE = Application.StartupPath + "\\REPORTS\\医保病人住院结算发票.rmf";

        public Form2()
        {
            InitializeComponent();
         
        }

        private void button1_Click(object sender, EventArgs e)
        {


           

            DataTable tbl = new DataTable();
            tbl.Columns.Add("INHOSID");
            tbl.Columns.Add("IDCARDNO");
            tbl.Columns.Add("hzxm");
            tbl.Columns.Add("PRE0");
            tbl.Columns.Add("PRE1");
            tbl.Columns.Add("PRE2");
            tbl.Columns.Add("PRE3");
            tbl.Columns.Add("PRE4");
            tbl.Columns.Add("PRE5");
            tbl.Columns.Add("PRE6");
            tbl.Columns.Add("PRE7");
            tbl.Columns.Add("PRE8");
            tbl.Columns.Add("PRE9");
            tbl.Columns.Add("TRANDT");
            tbl.Columns.Add("MEDICARENO");

            DataRow row = tbl.NewRow();

            row["INHOSID"] = "186555";
            row["IDCARDNO"] = "356565656565";
            row["hzxm"] = "测试患者";
            row["PRE0"] = "20";
            row["PRE1"] = "897";
            row["PRE2"] = "6";
            row["PRE3"] = "0";
            row["PRE4"] = "1";
            row["PRE5"] = "34";
            row["PRE6"] = "34";
            row["PRE7"] = "234";
            row["PRE8"] = "4545";
            row["PRE9"] = "45";
            row["TRANDT"] = "2011-02-11";
            row["MEDICARENO"] = "371100294924";

            tbl.Rows.Add(row);


            DataSet ds = new DataSet();
            ds.Tables.Add(tbl);
            string pp="0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|7607.37|4368.71|0|0|3238.66|0|0|4368.71|0|0|22.39|303.8|0|2912.47|0|0|371121|7281.18|0|0|4368.71|7281.18|0|0|0|0|303.8|0|0|2912.47|0|0|0|1|城镇居民基本医疗|2010-12-16|2010-12-29|2011-12|0|0|4368.71|5664.36|6.8|185.8|764|11|40|402|0|0|0|0|0|101.01|4.59|0|468|0|78|208|0|0|5471.76|713|402|0|96.42|390|208|7281.18|0|0|0|0|4368.71|0|0|0|0|0|0|.6|0|0|0|0|0|0|0|0|0|21||";
            PrintReport(ds, pp);

        }
        //打印报表
        private void PrintReport(DataSet ds, string prenolist)
        {

            RMReportEngine.RMReport rmReport = new RMReportEngine.RMReport();
            rmReport.Init(this, RMReportEngine.RMReportType.rmrtReport);

            //rmReport.AddDataSet(ds.Tables[0], "report");

            string inhosID = ds.Tables[0].Rows[0]["INHOSID"].ToString();
            string idCardNo = ds.Tables[0].Rows[0]["IDCARDNO"].ToString();
            string paientname = ds.Tables[0].Rows[0]["hzxm"].ToString();

            string TotalFee = ds.Tables[0].Rows[0]["PRE0"].ToString();
            string tczc = ds.Tables[0].Rows[0]["PRE1"].ToString();
            string dbzc = ds.Tables[0].Rows[0]["PRE2"].ToString();
            string zhzc = ds.Tables[0].Rows[0]["PRE3"].ToString();
            string xjzc = ds.Tables[0].Rows[0]["PRE4"].ToString();
            string gwybzzc = ds.Tables[0].Rows[0]["PRE5"].ToString();
            string zfje = ds.Tables[0].Rows[0]["PRE6"].ToString();
            string txfdzf = ds.Tables[0].Rows[0]["PRE7"].ToString();
            string dbfdzf = ds.Tables[0].Rows[0]["PRE8"].ToString();
            string yydf = ds.Tables[0].Rows[0]["PRE9"].ToString();
            string trandt = ds.Tables[0].Rows[0]["TRANDT"].ToString();

            string medicareNo = ds.Tables[0].Rows[0]["MEDICARENO"].ToString();



            string[] split = prenolist.ToString().Split('|');






            rmReport.AddVariable("患者姓名", paientname, true);
            rmReport.AddVariable("住院号", inhosID, true);
            rmReport.AddVariable("身份证号", idCardNo, true);
            rmReport.AddVariable("本次医疗费用", TotalFee, true);
            rmReport.AddVariable("本次统筹支出", tczc, true);
            rmReport.AddVariable("本次大病支出", dbzc, true);
            rmReport.AddVariable("本次账户支出", zhzc, true);
            rmReport.AddVariable("本次现金支出", xjzc, true);
            rmReport.AddVariable("本次公务员补助支出", gwybzzc, true);
            rmReport.AddVariable("本次自费金额", zfje, true);
            rmReport.AddVariable("统筹分段支付", txfdzf, true);
            rmReport.AddVariable("大病分段支付", dbfdzf, true);
            rmReport.AddVariable("医院垫付", yydf, true);
            rmReport.AddVariable("交易日期", trandt, true);
            rmReport.AddVariable("操作员", "liujian", true);


            rmReport.AddVariable("药品", split[56], true);
            rmReport.AddVariable("检查检验", split[59], true);
            rmReport.AddVariable("治疗", split[62], true);
            rmReport.AddVariable("手术麻醉", split[65], true);
            rmReport.AddVariable("材料", split[68], true);
            rmReport.AddVariable("服务设施", split[71], true);
            rmReport.AddVariable("其他", split[74], true);
            rmReport.AddVariable("起付线", split[27], true);
            rmReport.AddVariable("医保号", medicareNo, true);




            rmReport.LoadFromFile(REPORTS_FILE);

            ////打印 or 预览
            //if (rdbPreview.Checked)
            //{
            //    rmReport.ShowReport();
            //}
            //else
            //{

            //}

            rmReport.ShowReport();
            rmReport.Dispose();
            rmReport.Destroy();
        }


    }
}
